/**
 * 
 */
package sort.ui.components;

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * @author masaru-gotou
 *
 */
@SuppressWarnings("serial")
public class ResultPanel extends JPanel {
	/**
	 * 
	 */
	private JLabel l_validated;
	private JLabel l_sorted;
	private JLabel l_mem_usage;
	private JLabel l_stabled;
	private JLabel l_sort_algo;
	private JLabel l_time;

	public ResultPanel() {
		super(new GridLayout(0,2));
		add(new JLabel("algorythm"));
		l_sort_algo = new JLabel("-");
		add(l_sort_algo);
		add(new JLabel("validated"));
		l_validated = new JLabel("-");
		add(l_validated);
		add(new JLabel("sorted"));
		l_sorted = new JLabel("-");
		add(l_sorted);
		add(new JLabel("stabled"));
		l_stabled = new JLabel("-");
		add(l_stabled);
		add(new JLabel("elapsed time(msec)"));
		l_time = new JLabel("-");
		add(l_time);
		add(new JLabel("used mem(B)"));
		l_mem_usage = new JLabel("-");
		add(l_mem_usage);
	}
	public void setArgorythmName(String name ) {
		l_sort_algo.setText(name);
	}
	public void setTime(long time) {
		if ( time > 0 ) {
			l_time.setText(String.valueOf(time));
		}
	}
	public void setValidated(boolean validated) {
		l_validated.setText(String.valueOf(validated));
	}
	public void setSorted(boolean sorted) {
		l_sorted.setText(String.valueOf(sorted));
	}
	public void setMemoryUsage(long used) {
		l_mem_usage.setText(String.valueOf(used));
	}
	public void setStabled(boolean stabled) {
		l_stabled.setText(String.valueOf(stabled));
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                //Create and set up the window.
                JFrame frame = new JFrame("SortResultPanel Test");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                //Create and set up the content pane.
                ResultPanel panel = new ResultPanel();
        		panel.setOpaque(true);
        		frame.setContentPane(panel);

                //Display the window.
                frame.pack();
                frame.setVisible(true);
            }
        });
	}

}
